<?php

namespace App\Http\Middleware;

use Closure,Session,Request;

class OldMiddleware
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        //获得权限
        $action=Session::get('admin_power');
        $action=array_merge($action,array('/admin/top','/admin/left','/admin/main','/admin/checku'));
        $now_path=Request::getRequestUri();
        $now_path=substr($now_path, 15);
        //判断权限
        if(!in_array($now_path,$action)){

            return redirect('/gitDemo/public/admin/login');
            
        }
        $now_path='/gitDemo/public'.$now_path;
        return $next($request);
    }
    public function terminate($request, $response)
    {
        // Store the session data...
    }
}
